From 00e5f9571f40450bf538c32ffb0c88374ea04372 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 16 May 2017 07:07:36 -0700 Subject: [PATCH] Don't use a bare checkout of the index Both old and new Cargo share the same index, so be sure to maintain compatibility by initializing a non-bare repository for the index. Note that a nightly Cargo still won't check out the index, but when an older Cargo comes along and tries to check it out then it'll work. Closes #4058 --- src/cargo/sources/registry/remote.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/cargo/sources/registry/remote.rs b/src/cargo/sources/registry/remote.rs index 78c9cb5b5..eb1d03168 100644 --- a/src/cargo/sources/registry/remote.rs +++ b/src/cargo/sources/registry/remote.rs @@ -63,7 +63,19 @@ impl<'cfg> RemoteRegistry<'cfg> { self.config, "the registry index")?; let _ = lock.remove_siblings(); - Ok(git2::Repository::init_bare(&path)?) + + // Note that we'd actually prefer to use a bare repository + // here as we're not actually going to check anything out. + // All versions of Cargo, though, share the same CARGO_HOME, + // so for compatibility with older Cargo which *does* do + // checkouts we make sure to initialize a new full + // repository (not a bare one). + // + // We should change this to `init_bare` whenever we feel + // like enough time has passed or if we change the directory + // that the folder is located in, such as by changing the + // hash at the end of the directory. + Ok(git2::Repository::init(&path)?) } } }) -- 2.30.2